<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get attributes from a search result entry</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ldap-free-result.html">« ldap_free_result</a></li>
      <li style="float: right;"><a href="function.ldap-get-dn.html">ldap_get_dn »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.ldap.html">LDAP 函数</a></li>
    <li>Get attributes from a search result entry</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ldap-get-attributes" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ldap_get_attributes</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ldap_get_attributes</span> &mdash; <span class="dc-title">Get attributes from a search result entry</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ldap-get-attributes-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ldap_get_attributes</strong></span>(<span class="methodparam"><span class="type"><a href="class.ldap-connection.html" class="type LDAP\Connection">LDAP\Connection</a></span> <code class="parameter">$ldap</code></span>, <span class="methodparam"><span class="type"><span class="type LDAP\ResultEntry">LDAP\ResultEntry</span></span> <code class="parameter">$entry</code></span>): <span class="type">array</span></div>

  <p class="para rdfs-comment">
   Reads attributes and values from an entry in the search result. 
  </p>
  <p class="para">
   Having located a specific entry in the directory, you can find out what
   information is held for that entry by using this call. You would use this
   call for an application which &quot;browses&quot; directory entries and/or where you
   do not know the structure of the directory entries. In many applications
   you will be searching for a specific attribute such as an email address or
   a surname, and won&#039;t care what other data is held.
   <div class="informalexample">
    <div class="example-contents">
<div class="cdata"><pre>
return_value[&quot;count&quot;] = number of attributes in the entry
return_value[0] = first attribute
return_value[n] = nth attribute

return_value[&quot;attribute&quot;][&quot;count&quot;] = number of values for attribute
return_value[&quot;attribute&quot;][0] = first value of the attribute
return_value[&quot;attribute&quot;][i] = (i+1)th value of the attribute
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ldap-get-attributes-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">ldap</code></dt>

     <dd>

      <p class="para">
       通过 <span class="function"><a href="function.ldap-connect.html" class="function">ldap_connect()</a></span> 返回的 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span> 实例。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">entry</code></dt>

     <dd>

      <p class="para">
       <span class="classname"><a href="class.ldap-result-entry.html" class="classname">LDAP\ResultEntry</a></span> 实例。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ldap-get-attributes-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a complete entry information in a multi-dimensional array
   on success and <strong><code>false</code></strong> on error.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.ldap-get-attributes-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">ldap</code> 参数接受 <span class="classname"><a href="class.ldap-connection.html" class="classname">LDAP\Connection</a></span>
  实例，之前接受 <a href="language.types.resource.html" class="link">资源(resource)</a>。
 </td>
</tr>

     <tr>
 <td>8.1.0</td>
 <td>
  The <code class="parameter">entry</code> parameter expects an <span class="classname"><a href="class.ldap-result-entry.html" class="classname">LDAP\ResultEntry</a></span>
  instance now; previously, a <a href="language.types.resource.html" class="link">资源(resource)</a> was expected.
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.ldap-get-attributes-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4344">
    <p><strong>示例 #1 
     Show the list of attributes held for a particular directory entry
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;$ds&nbsp;is&nbsp;a&nbsp;valid&nbsp;LDAP\Connection&nbsp;instance&nbsp;for&nbsp;a&nbsp;directory&nbsp;server<br /><br />//&nbsp;$sr&nbsp;is&nbsp;a&nbsp;valid&nbsp;search&nbsp;result&nbsp;from&nbsp;a&nbsp;prior&nbsp;call&nbsp;to<br />//&nbsp;one&nbsp;of&nbsp;the&nbsp;ldap&nbsp;directory&nbsp;search&nbsp;calls<br /><br /></span><span style="color: #0000BB">$entry&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_first_entry</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sr</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$attrs&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ldap_get_attributes</span><span style="color: #007700">(</span><span style="color: #0000BB">$ds</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$entry</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$attrs</span><span style="color: #007700">[</span><span style="color: #DD0000">"count"</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;attributes&nbsp;held&nbsp;for&nbsp;this&nbsp;entry:&lt;p&gt;"</span><span style="color: #007700">;<br /><br />for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$attrs</span><span style="color: #007700">[</span><span style="color: #DD0000">"count"</span><span style="color: #007700">];&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$attrs</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">]&nbsp;.&nbsp;</span><span style="color: #DD0000">"&lt;br&nbsp;/&gt;"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ldap-get-attributes-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ldap-first-attribute.html" class="function" rel="rdfs-seeAlso">ldap_first_attribute()</a> - Return first attribute</span></li>
    <li class="member"><span class="function"><a href="function.ldap-next-attribute.html" class="function" rel="rdfs-seeAlso">ldap_next_attribute()</a> - Get the next attribute in result</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>